home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / AIAT 1.0.1 / Headers / Analysis / IACharStream.h < prev    next >
Encoding:
Text File  |  1997-09-11  |  2.1 KB  |  70 lines  |  [TEXT/CWIE]

  1. // IACharStream.h
  2. //    Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. #pragma once
  5. #ifndef IACharStream_h
  6. #define IACharStream_h
  7. #pragma import on
  8.  
  9. #include "IACommon.h"
  10.  
  11. #pragma IA_BEGIN_EXPORTS
  12.  
  13. class IACharStream : public IAObject {
  14. public:
  15.                     IACharStream();
  16.     virtual            ~IACharStream();
  17.     // common operations are handled inline by base class
  18.  
  19.     // note: eos is assumed to be false, and is only set when eos is reached
  20.     // also, when eos is set, the return value should be ignored
  21.     char            GetNextChar(bool* eos) { 
  22.                         return nextChar < endChar ? *(nextChar++) : ReadPastEndOfBuffer(eos);
  23.                     }
  24.  
  25.     inline uint32    CurrentPos() { return bufferPos + (nextChar - buffer); }
  26.     
  27.     void            GetTextSpan(char* buffer, uint32 startPos, uint32 endPos);
  28.  
  29.     // subclasses may wish to implement a faster version of this
  30.     virtual void    AdvanceTo(uint32 pos);
  31.     
  32.     // accessors needed for string-based subclasses
  33.     char*            GetBuffer() const { return buffer; } // returns current buffer
  34.     void            SetBuffer(char* newValue) { buffer = newValue; } // sets current buffer
  35.     
  36.     char*            GetNextCharInBuffer() const { return nextChar; }
  37.     void            SetNextCharInBuffer(char* newValue) { nextChar = newValue; }
  38.     
  39.     char*            GetEndChar() const { return endChar; }
  40.     void            SetEndChar(char* newValue) { endChar = newValue; }
  41.     
  42.     uint32            GetBufferPos() const { return bufferPos; }
  43.     void            SetBufferPos(uint32 newValue) { bufferPos = newValue; }
  44.     
  45. protected:
  46.     // subclasses must implement only this one method
  47.     virtual uint32    GetNextBuffer(char* buffer, uint32 bufferLen) = 0;
  48.     
  49. private:
  50.     char            ReadPastEndOfBuffer(bool *eos);
  51.     char*            lastBuffer;                    // the previous buffer
  52.     char*            lastEndChar;                // the end of the previous buffer
  53.  
  54.                     IACharStream(IACharStream&);// don't define a copy constructor
  55.                     
  56.     char*            buffer;                        // the current buffer
  57.     char*            nextChar;                    // pointer to the next character to read in buffer
  58.     char*            endChar;                    // pointer to the end of the current buffer            
  59.     uint32            bufferPos;                    // position of the first char in buffer
  60.  
  61. };
  62.  
  63. IAExceptionCode            TextSpanUnavailable = 'VTSU';
  64.  
  65. #pragma IA_END_EXPORTS
  66.  
  67. #pragma import reset
  68.  
  69. #endif
  70.